package com.shiny.concurrency4java.atomic;

import lombok.Getter;
import lombok.extern.slf4j.Slf4j;

import java.util.concurrent.atomic.AtomicStampedReference;

/*
* ABA的问题
*/
@Slf4j
public class StampReferenceExample {

    @Getter
    private AtomicStampedReference<Integer> stamp = new AtomicStampedReference<Integer>(0,1);

    public static void main(String[] args) {
        StampReferenceExample example = new StampReferenceExample();
        example.getStamp().compareAndSet(0,2,1,5);
        example.getStamp().compareAndSet(1,3,4,7);
        example.getStamp().compareAndSet(2,1,5,4);
        log.info("reference {} stamp{}", example.getStamp().getReference(),example.getStamp().getStamp());
        return;
    }

}
